// This is part of the Microsoft Foundation Classes C++ library.
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
// This source code is only intended as a supplement to the
// Microsoft Foundation Classes Reference and related
// electronic documentation provided with the library.
// See these sources for detailed information regarding the
// Microsoft Foundation Classes product.
//
// mfcieVw.h : interface of the CMfcieView class
//
/////////////////////////////////////////////////////////////////////////////

#if !defined(AFX_MFCIEVIEW_H__47FF4085_CE1B_11D0_BEB6_00C04FC99F83__INCLUDED_)
#define AFX_MFCIEVIEW_H__47FF4085_CE1B_11D0_BEB6_00C04FC99F83__INCLUDED_

#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000

typedef CComQIPtr< IHTMLDocument2, &IID_IHTMLDocument2 > CHTMLDocument;
typedef CComQIPtr< IHTMLElement, &IID_IHTMLElement > CHTMLElement;
typedef CComQIPtr< IHTMLAnchorElement, &IID_IHTMLAnchorElement > CHTMLAnchorElement;
// CJSHost command target

class CJSHost : public CCmdTarget
{
	friend class CMfcieView;
	DECLARE_DYNAMIC(CJSHost)

public:
	CJSHost(CMfcieView*pView);
	virtual ~CJSHost();

	virtual void OnFinalRelease();

protected:
	CMfcieView *m_pView;
	DECLARE_MESSAGE_MAP()
	// Generated OLE dispatch map functions
	//{{AFX_DISPATCH(CJSHost)
	afx_msg long Test(LPCTSTR strCmd);
	//}}AFX_DISPATCH
	DECLARE_DISPATCH_MAP()
	DECLARE_INTERFACE_MAP()
};

class CMfcieView : public CHtmlView
{
	friend class CJSHost;
protected: // create from serialization only
	CMfcieView();
	DECLARE_DYNCREATE(CMfcieView)

// Attributes
public:
	CMfcieDoc* GetDocument();
	CHTMLDocument GetHtmlDocument() {
		return CHtmlView::GetHtmlDocument(); }

// Operations
public:

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CMfcieView)
	public:
	virtual void OnDraw(CDC* pDC);  // overridden to draw this view
	virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
	virtual void OnInitialUpdate();
	//}}AFX_VIRTUAL
	void OnTitleChange(LPCTSTR lpszText);
	void OnDocumentComplete(LPCTSTR lpszUrl);
	void OnBeforeNavigate2(LPCTSTR lpszURL, DWORD nFlags,
		LPCTSTR lpszTargetFrameName, CByteArray& baPostedData,
		LPCTSTR lpszHeaders, BOOL* pbCancel);

// Implementation
public:
	virtual ~CMfcieView();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

protected:
	CString GetLogText();
	void RunLastScript();
	void RunScriptFile( LPCTSTR strFile );
	void RunScript( LPCTSTR strScript );
	CString m_strLastScript;
	int m_nLogLength;
	// Log text to file
	void Log(void);
	// Get javascript variable
	HRESULT GetJSValue(LPCTSTR strName, CComVariant & v);
	// Set javascript variable
	HRESULT SetJSValue(LPCTSTR strName, const CComVariant & v);
	// Run javascript function
	HRESULT RunJSFunction(LPCTSTR strName, CComVariant *pVariantReturn = NULL);
	// Global variable transmit between pages
	CComVariant m_vGlobalVariable;
	// Global log string
	CComVariant m_vLog;
	// Property
	DWORD m_dwProperty;
	// Host
	CJSHost m_host;
	// Save the settings if changed
	HRESULT CheckSettings(void);
	// Load settings
	void LoadSettings(LPCTSTR strFile);
	// url name
	CString m_strDoc;
	// Script to run
	CString m_strRunScript;
	CString m_strLastScriptFile;
	// Log file
	CString m_strLogFile;
	// INI file
	CString m_strINIFile;
	// Property changed
	void ChangeProperty(void);
	int m_nNotReady;

	virtual BOOL OnAmbientProperty(COleControlSite* pSite, DISPID dispid, VARIANT* pvar);
// Generated message map functions
protected:
	//{{AFX_MSG(CMfcieView)
	afx_msg void OnGoBack();
	afx_msg void OnGoForward();
	afx_msg void OnGoSearchTheWeb();
	afx_msg void OnGoStartPage();
	afx_msg void OnViewStop();
	afx_msg void OnViewRefresh();
	afx_msg void OnHelpWebTutorial();
	afx_msg void OnHelpOnlineSupport();
	afx_msg void OnHelpMicrosoftOnTheWebFreeStuff();
	afx_msg void OnHelpMicrosoftOnTheWebFrequentlyAskedQuestions();
	afx_msg void OnHelpMicrosoftOnTheWebGetFasterInternetAccess();
	afx_msg void OnHelpMicrosoftOnTheWebMicrosoftHomePage();
	afx_msg void OnHelpMicrosoftOnTheWebSearchTheWeb();
	afx_msg void OnHelpMicrosoftOnTheWebSendFeedback();
	afx_msg void OnHelpMicrosoftOnTheWebInternetStartPage();
	afx_msg void OnHelpMicrosoftOnTheWebBestOfTheWeb();
	afx_msg void OnViewFontsLargest();
	afx_msg void OnViewFontsLarge();
	afx_msg void OnViewFontsMedium();
	afx_msg void OnViewFontsSmall();
	afx_msg void OnViewFontsSmallest();
	afx_msg void OnFileOpen();
	afx_msg void OnViewRun();
	afx_msg void OnViewRunFile();
	afx_msg void OnViewRunLast();
	afx_msg void OnViewRunLastFile();
	afx_msg void OnViewDump();
	afx_msg void OnTimer(UINT nIDEvent);
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
public:
	virtual void OnNavigateComplete2(LPCTSTR strURL);
protected:
	// Get the script to run
	CString GetScript(CHTMLDocument doc);
public:
	// Set log file
	void SetLogFile(LPCTSTR strLogFile);
	// Set ini file
	void SetINIFile(LPCTSTR strINIFile);
};

#ifndef _DEBUG  // debug version in mfcieView.cpp
inline CMfcieDoc* CMfcieView::GetDocument()
   { return (CMfcieDoc*)m_pDocument; }
#endif

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_MFCIEVIEW_H__47FF4085_CE1B_11D0_BEB6_00C04FC99F83__INCLUDED_)
